import axios from 'axios';
var expendExcel=function(url,params,type){
    // console.log(params);
    var type=type||[];
    return new Promise((resolve,reject)=>{
        resolve('成功');
        setTimeout(()=>{
            var downloadElement = document.createElement('a');
            var str='';
            for(var key in params){//读取传过来的参数
                if(type.indexOf(key)!=-1){//只提取需要传的参数
                    str+=`${key}=${params[key]}&`;
                }else if(type.indexOf('all')!=-1){
                    str+=`${key}=${params[key]}&`;
                }
                if(!type){//如果没有传参数，就是只传时间
                    str=`startTime=${params.startTime||''}&endTime=${params.endTime||''}`;
                }
            }
            str=str.replace(/&$/g,'');//去除最后一个&
            downloadElement.href=url+'?'+str;
            document.body.appendChild(downloadElement);
            downloadElement.click();
            document.body.removeChild(downloadElement);
        },1000)
    })
}
export { expendExcel }